﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using DG.Tweening;

public class ChildrenSeqFade : MonoBehaviour {

    public IEnumerator FadeIn() {
        
        foreach (Transform child in transform)
        {
            child.gameObject.SetActive(false);
        }

        gameObject.SetActive(true);

        foreach (Transform child in transform)
        {
            
            Graphic graphic = child.GetComponent<Image>();
            if(graphic == null)
                graphic = child.GetComponent<Text>();
            graphic.DOFade(0, 0.001f).OnComplete(delegate() {
                child.gameObject.SetActive(true);
                graphic.DOFade(1f, 1f);
            });
            
            yield return new WaitForSeconds(0.5f);
        }
    }
}
